<?php

namespace Api\Pay;

/**
 * Class Deduce
 * @package Api\Pay
 * @description 代收服务
 */
class Deduce extends Base {

    const URI_DEDUCE_SINGLE = "/deduce/single";  //代收-单笔

    /**
     * 代收-单笔
     *
     * @param string $appkey 应用appkey
     * @param string $inner_mer_id 内部商户号
     * @param string $uid 用户uid
     * @param string $buz_id 业务订单号
     * @param string $request_time 请求时间, 1970至今秒数
     * @param string $card_no 代收卡号
     * @param int $amt 订单金额, 单位: 人民币-分
     * @param string $callback_url default null 业务交易结果异步通知url
     * @param array $options default array() 订单选项参数
     *                                       purpose O string(0,150) 备注
     *
     * @return bool true-代收请求成功 false-代收请求失败
     */
    public function single($appkey, $inner_mer_id, $uid, $buz_id, $request_time,
                           $card_no, $amt, $callback_url = null, array $options = array()) {
        $params = array(
            "mer_id" => $inner_mer_id,
            "uid" => $uid,
            "buz_id" => $buz_id,
            "request_time" => $request_time,
            "card_no" => $card_no,
            "amt" => $amt,
            "callback_url" => $callback_url,
            "options" => json_encode($options),
        );

        $resp_data = $this->request($appkey, self::URI_DEDUCE_SINGLE, $params);

        return ($resp_data && $resp_data["result"]);
    }

} 